package io.aicn.lowcode.entity.dbmanager;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * 数据表信息实体类
 * 
 * @author lowcode-generator
 * @since 2025-01-25
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("dbm_data_table")
public class DataTable {

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 数据源ID
     */
    @TableField("datasource_id")
    private Long datasourceId;

    /**
     * 数据库名
     */
    @TableField("database_name")
    private String databaseName;

    /**
     * 表名
     */
    @TableField("table_name")
    private String tableName;

    /**
     * 表注释
     */
    @TableField("table_comment")
    private String tableComment;

    /**
     * 存储引擎
     */
    @TableField("engine")
    private String engine;

    /**
     * 字符集
     */
    @TableField("charset")
    private String charset;

    /**
     * 排序规则
     */
    @TableField("collation")
    private String collation;

    /**
     * 行数
     */
    @TableField("row_count")
    private Long rowCount;

    /**
     * 数据大小(字节)
     */
    @TableField("data_size")
    private Long dataSize;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    /**
     * 创建人
     */
    @TableField(value = "create_by", fill = FieldFill.INSERT)
    private String createBy;

    /**
     * 存储引擎枚举
     */
    public enum Engine {
        INNODB("InnoDB", "InnoDB存储引擎"),
        MYISAM("MyISAM", "MyISAM存储引擎"),
        MEMORY("MEMORY", "内存存储引擎");

        private final String code;
        private final String description;

        Engine(String code, String description) {
            this.code = code;
            this.description = description;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }
    }
}